/**
 * 
 */
package com.owen.he.jee.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ibatis.common.util.PaginatedList;
import com.owen.he.jee.dao.impl.ibatis.LimitSqlExecutor;

/**
 * @author chenly
 * 
 * @version createtime:2016-7-29 上午10:31:26
 */
public class BaseDAOV2Impl extends PasBaseDAO implements IBaseDAO {

	private static final Logger log = LoggerFactory
			.getLogger(BaseDAOV2Impl.class);
	
	
	

	public int deleteByPrimaryKey(String sqlKey, Object key) {
		try {

			return super.deleteByPrimaryKey(sqlKey, key);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public void insert(String sqlKey, Object pojo) {
		try {
			super.insert(sqlKey, pojo);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public Object selectByPrimaryKey(String sqlKey, Object key) {
		try {
			return super.selectByPrimaryKey(sqlKey, key);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public int updateByPrimaryKey(String sqlKey, Object key) {
		try {
			return super.updateByPrimaryKey(sqlKey, key);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public List selectInfoByPara(String sqlKey, Map map) {
		List list = new ArrayList();
		try {
			list = super.selectInfoByPara(sqlKey, map);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public List selectPageInfoByPara(String sqlKey, Map map, int starRow,
			int pageSize) {
		List list = new ArrayList();
		try {
			list = super.selectPageInfoByPara(sqlKey, map, starRow, pageSize);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public List selectPageInfoByParaForSp(String sqlKey, Map map, int starRow,
			int pageSize) {
		List list = new ArrayList();
		try {
			list = super.selectPageInfoByParaForSp(sqlKey, map, starRow,
					pageSize);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public Integer selectCountRows(String sqlKey, Map map) {
		Integer count = 0;
		try {
			count = super.selectCountRows(sqlKey, map);
			return count;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public PaginatedList selectPage(String sqlKey, Map map, int pageSize) {
		PaginatedList list = null;
		try {
			list = super.selectPage(sqlKey, map, pageSize);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public List selectListByPara(String sqlKey, Object para) {
		List list = new ArrayList();
		try {
			list = super.selectListByPara(sqlKey, para);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public List selectPageInfoByParaNolazy(String sqlKey, Map map, int starRow,
			int pageSize) {
		List list = new ArrayList();
		try {
			list = super.selectPageInfoByParaNolazy(sqlKey, map, starRow,
					pageSize);
			return list;
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public String getDialect() {
		try {
			LimitSqlExecutor exc = (LimitSqlExecutor) getSqlExecutor();

			return exc.getDialect().getClass().getName();
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public void batchInsert(String sqlKey, List<Object> list) {
		try {

			super.batchInsert(sqlKey, list);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public void batchUpdate(String sqlKey, List<Object> list) {
		try {
			super.batchUpdate(sqlKey, list);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public Map selectMapByPara(String sqlKey, Object para, String keyPro) {
		try {
			return super.selectMapByPara(sqlKey, para, keyPro);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	public Map selectMapByPara(String sqlKey, Object para, String keyPro,
			String valueProp) {
		try {
			return super.selectMapByPara(sqlKey, para, keyPro, valueProp);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}


	/* (non-Javadoc)
	 * @see com.pas.cloud.ibatis.spring.base.IBaseDAO#queryForObject(java.lang.String, java.lang.Object)
	 */
	@Override
	public Object queryForObject(String sqlKey, Object para) {
		try {

			return super.queryForObject(sqlKey, para);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
		
	}


	@Override
	public Object selectByPrimaryKey2(String sqlKey, Map map) {
		try {
			return super.selectByPrimaryKey(sqlKey, map);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

	@Override
	public int deleteByPrimaryKey2(String sqlKey, Map map) {
		try {

			return super.deleteByPrimaryKey(sqlKey, map);
		} catch (PasCloudException ex) {
			log.error("异常", ex);
			throw new PasCloudException("异常:" + ex.getMessage());
		}
	}

}
